home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 January: Mac OS SDK / Dev.CD Jan 96 SDK / Dev.CD Jan 96 SDK1.toast / Development Kits (Disc 1) / QuickDraw™ GX / Programming Stuff / Sample Code / Typography Samples / Dave’s Fab Samples ƒ / Letterspacing.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-04-10  |  2.1 KB  |  90 lines  |  [TEXT/KAHL]

  1. #include <Types.h>
  2. #include <QuickDraw.h>
  3. #include <Fonts.h>
  4. #include <Windows.h>
  5. #include <Menus.h>
  6. #include <SegLoad.h>
  7. #include <Memory.h>
  8. #include <Desk.h>
  9.  
  10. #include "graphics routines.h"
  11. #include "graphics libraries.h"
  12. #include "graphics toolbox.h"
  13.  
  14. #include "layout types.h"
  15. #include "layout routines.h"
  16. #include "layout library.h"
  17.  
  18. #include "SampleInterface.h"
  19.  
  20. short MyStrLen(char *x);
  21. static short MyStrLen(x)
  22. char    *x;
  23.     {
  24.     short c = 0;
  25.     while (*x++) c++;
  26.     return c;
  27.     }    /* MyStrLen */
  28.  
  29. void LetterSpacing(WindowPtr sampleWindow)
  30.     {
  31.     /* Variables */
  32.     char        *myString = "AAABBBBAAA";
  33.     gxPoint        myPoint;
  34.     gxRunControls    gxRunControls;
  35.     gxShape        layout;
  36.     short        len, level = 0, runLengths[3];
  37.     gxStyle        regularStyle, tweakedStyle, styleArray[3];
  38.     gxViewPort    aViewPort;
  39.     
  40.     /* Initialization */
  41.     
  42.     myPoint.x = ff(30);
  43.     myPoint.y = ff(50);
  44.     
  45.     /* Standard opening game */
  46.     
  47.     aViewPort = GXNewWindowViewPort(sampleWindow);
  48.     SetDefaultViewPort(aViewPort);
  49.     
  50.     len = MyStrLen(myString);
  51.     runLengths[0] = runLengths[2] = 3;
  52.     runLengths[1] = 4;
  53.     
  54.     regularStyle = NewLayoutStyle((char *) "\pHoefler Text", ff(50), 0, nil, nil, 0, nil);
  55.     tweakedStyle = NewLayoutStyle((char *) "\pHoefler Text", ff(50), 0, nil, nil, 0, nil);
  56.     
  57.     styleArray[0] = styleArray[2] = regularStyle;
  58.     styleArray[1] = tweakedStyle;
  59.     
  60.     layout = GXNewLayout(
  61.         1, &len, (void *) &myString,
  62.         3, runLengths, styleArray,
  63.         1, &len, &level,
  64.         nil, &myPoint);
  65.     GXDrawShape(layout);
  66.     
  67.     InitializeRunControls(&gxRunControls);
  68.     gxRunControls.beforeWithStreamShift = ff(10);
  69.     GXSetStyleRunControls(tweakedStyle, &gxRunControls);
  70.     GXMoveShape(layout, 0, ff(100));
  71.     GXDrawShape(layout);
  72.     
  73.     gxRunControls.beforeWithStreamShift = 0;
  74.     gxRunControls.afterWithStreamShift = ff(10);
  75.     GXSetStyleRunControls(tweakedStyle, &gxRunControls);
  76.     GXMoveShape(layout, 0, ff(100));
  77.     GXDrawShape(layout);
  78.     
  79.     gxRunControls.afterWithStreamShift = 0;
  80.     gxRunControls.crossStreamShift = ff(10);
  81.     GXSetStyleRunControls(tweakedStyle, &gxRunControls);
  82.     GXMoveShape(layout, 0, ff(100));
  83.     GXDrawShape(layout);
  84.  
  85.     GXDisposeShape(layout);
  86.     GXDisposeStyle(regularStyle);
  87.     GXDisposeStyle(tweakedStyle);
  88.     GXDisposeViewPort(aViewPort);
  89.     }    /* main */
  90.